#region Using directives

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;

using FighterChessEngine.FC_Fighter;
using FighterChessEngine.Enum;

#endregion

namespace FighterChessSkin.FC_Messenger
{
    /// <summary>
    /// Summary description for frmMessageBox.
    /// </summary>
    public class frmMessageBox : System.Windows.Forms.Form
    {
        private Label lbMessage;

        public frmMessageBox()
        {
            InitializeComponent();
        }

        public frmMessageBox(Fighter speaker, string message)
            : this()
        {
            string speakerName = speaker.Owner == Owner.White 
                ? "W" + speaker.Name
                : "B" + speaker.Name;

            lbMessage.Text = speakerName + " says: \r\n";
            lbMessage.Text += "\"" + message + "\"";
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.lbMessage = new System.Windows.Forms.Label();
            // 
            // lbMessage
            // 
            this.lbMessage.Font = new System.Drawing.Font("Tahoma", 18F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))));
            this.lbMessage.ForeColor = System.Drawing.Color.Red;
            this.lbMessage.Location = new System.Drawing.Point(7, 69);
            this.lbMessage.Size = new System.Drawing.Size(230, 190);
            this.lbMessage.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            // 
            // frmMessageBox
            // 
            this.ClientSize = new System.Drawing.Size(240, 320);
            this.ControlBox = false;
            this.Controls.Add(this.lbMessage);
            this.Location = new System.Drawing.Point(0, 0);
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.Load += new System.EventHandler(this.frmMessageBox_Load);

        }

        #endregion

        private Timer delayTimer = new Timer();
        private int delayDuration = 0;

        private void frmMessageBox_Load(object sender, EventArgs e)
        {
            //this.Location = new Point(0, 80);
            //this.Invalidate();
            delayTimer.Interval = 650;
            delayTimer.Tick += new EventHandler(delayTimer_Tick);
            delayTimer.Enabled = true;
        }

        void delayTimer_Tick(object sender, EventArgs e)
        {
            if (delayDuration == 2)
            {
                delayTimer.Enabled = false;
                this.DialogResult = DialogResult.OK;
            }

            delayDuration++;
        }
    }
}
